package com.itheima.Test;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Method;

public class MyTest002 {
    public static void main(String[] args) throws IOException {
        MyQQ qq = new MyQQ();
        Class<MyQQ> c = MyQQ.class;
        Method[] methods = c.getMethods();
        BufferedWriter bw = new BufferedWriter(new FileWriter("Day21codes\\bug.txt"));
        int count = 0;
        for (Method method : methods) {
            if (method.isAnnotationPresent(Chack.class)) {
                try {
                    method.invoke(qq);
                } catch (Exception e) {
                    count++;
                    bw.write("在" + method.getName() + "这个方法中出现了" + e.getCause().toString());
                    bw.newLine();
                    bw.write("--------------------------------------------------------------");
                    bw.newLine();
                }

            }
        }
        bw.newLine();
        bw.newLine();
        bw.write("在这些方法中一共出现了"+count+"个异常");
        bw.close();
    }
}
